﻿Imports System
Imports System.Reflection
Imports System.Workflow.ComponentModel

Namespace System.Workflow.ComponentModel.Compiler
    Public NotInheritable Class PropertyValidationContext
        ' Methods
        Public Sub New(ByVal propertyOwner As Object, ByVal dependencyProperty As DependencyProperty)
            Me.propertyName = String.Empty
            If (propertyOwner Is Nothing) Then
                Throw New ArgumentNullException("propertyOwner")
            End If
            Me.propertyOwner = propertyOwner
            Me.propertyInfo = dependencyProperty
        End Sub

        Public Sub New(ByVal propertyOwner As Object, ByVal propertyInfo As PropertyInfo, ByVal propertyName As String)
            Me.propertyName = String.Empty
            If (propertyName Is Nothing) Then
                Throw New ArgumentNullException("propertyName")
            End If
            If (propertyOwner Is Nothing) Then
                Throw New ArgumentNullException("propertyOwner")
            End If
            Me.propertyOwner = propertyOwner
            Me.propertyName = propertyName
            Me.propertyInfo = propertyInfo
        End Sub


        ' Properties
        Public ReadOnly Property [Property] As Object
            Get
                Return Me.propertyInfo
            End Get
        End Property

        Public ReadOnly Property PropertyName As String
            Get
                If TypeOf Me.propertyInfo Is DependencyProperty Then
                    Return DirectCast(Me.propertyInfo, DependencyProperty).Name
                End If
                Return Me.propertyName
            End Get
        End Property

        Public ReadOnly Property PropertyOwner As Object
            Get
                Return Me.propertyOwner
            End Get
        End Property


        ' Fields
        Private propertyInfo As Object
        Private propertyName As String
        Private propertyOwner As Object
    End Class
End Namespace

